package com.jhhc.StormSurgeForecast.StormSurge.ServiceImpl;

import com.jhhc.StormSurgeForecast.AstronomicalTide.Dao.PoiinfoDao;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.GZABO.LongitudeAndLatitude;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.GZABO.Poi;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.GZABO.Poiinfo;
import com.jhhc.StormSurgeForecast.StormSurge.Service.PoiinfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * (Poiinfo)表服务实现类
 *
 * @author makejava
 * @since 2023-04-27 10:31:14
 */
@Service("PoiinfoService")
public class PoiinfoServiceImpl implements PoiinfoService {
    @Resource
    private PoiinfoDao poiinfoDao;
    @Override
    public Poi queryById() {
        List<Poiinfo> poiinfos = poiinfoDao.queryById();
        Poi poi = new Poi();
        List<LongitudeAndLatitude> d = new ArrayList<>();
        List<LongitudeAndLatitude> x = new ArrayList<>();
        for (int i = 0; i < poiinfos.size(); i++) {
            LongitudeAndLatitude longitudeAndLatitude = new LongitudeAndLatitude();
            if (poiinfos.get(i).getPoiid().contains("E")) {
                longitudeAndLatitude.setLatitude(poiinfos.get(i).getLatitudel());
                longitudeAndLatitude.setLongitude(poiinfos.get(i).getLongitude());
                d.add(longitudeAndLatitude);
            }
            if (poiinfos.get(i).getPoiid().contains("W")) {
                longitudeAndLatitude.setLatitude(poiinfos.get(i).getLatitudel());
                longitudeAndLatitude.setLongitude(poiinfos.get(i).getLongitude());
                x.add(longitudeAndLatitude);
            }
        }
        poi.setD(d);
        poi.setX(x);
        return poi;
    }
}
